package org.stream.answerduel.controller.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.stream.answerduel.controller.BaseController;
import org.stream.answerduel.dto.Result;
import org.stream.answerduel.service.RankService;
import org.stream.answerduel.vo.RankVo;

import java.util.List;

/**
 *
 * 功能描述：用于请求与返回排行榜数据的控制器
 * @author  郭榕
 * @Date    2019/7/10 13:03
 *
 *
 */
@Api("排行榜控制器接口")
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/api/rank")
public class RankController extends BaseController {

    @Autowired
    private RankService rankService;
    /**
     * 功能描述：查询世界排行，返回列表给前端;
     * @param  wechatId
     * @return Result<List<RankVo>>
     */
    @ApiOperation(value = "查询", notes = "查询世界排行榜")
    @ApiImplicitParams({})
    @GetMapping("checkworld")
    public Result<List<RankVo>> checkworld(String wechatId){

        List<RankVo> rankVos = rankService.selectWorldRank(wechatId);

        return  new Result<List<RankVo>>().ok("世界排行",rankVos);
    }

    /**
     * 功能描述：查询好友排行，返回列表给前端;
     * @param  wechatId
     * @return Result<List<RankVo>>
     */
    @ApiOperation(value = "查询", notes = "查询好友排行榜")
    @ApiImplicitParams({})
    @GetMapping("checkfriend")
    public Result<List<RankVo>> checkfriend(String wechatId)
    {
        List<RankVo> rankVos = rankService.selectFriendRank(wechatId);
        return  new Result<List<RankVo>>().ok("好友排行",rankVos);
    }


}
